package com.zhai.domain.activity.event;

import com.zhai.types.event.BaseEvent;
import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @Description: 活动sku库存为0时发送队列消息进行消费
 * @ClassName: ActivitySkuStockZeroMessageEvent
 * @Author: zhaiyongxin
 * @Date: 2025/2/24 16:19
 * @Version: 1.0
 */
@Component
public class ActivitySkuStockZeroMessageEvent extends BaseEvent<Long> {

    @Value("${spring.rabbitmq.topic.activity_sku_stock_zero}")
    private String topic;

    @Override
    public EventMessage buildEventMessage(Long sku) {
        return EventMessage.builder()
                .id(RandomStringUtils.randomNumeric(11))
                .timestamp(new Date())
                .data(sku)
                .build();
    }

    @Override
    public String topic() {
        return topic;
    }
}
